package com.mrent.entity;

import com.alipay.util.Payment;
import com.mrent.util.ConfigHelper;

public class Alipay {

	/** ********************商品信息************************* */

	private String body;// 商品描述.

	private String subject;// 商品名称.

	private String price;// 商品单价.

	private String quantity;// 商品数量.

	private String show_url;// 商品展示地址.

	private String payment_type = "1";// 商品购买.

	private String discount;// 商品折扣.

	private String out_trade_no;// 订单号.

	/** *******************商家帐户信息******************************* */

	private String service = "trade_create_by_buyer";// 标准实物双接口服务.

	private String sign_type = "MD5";// 签名方式,md5

	private String input_charset = "utf-8";// 字符编码.

	private String partner;// 商家ID.

	private String key;// 安全检验码.

	private String seller_email;// 卖家支付宝帐户

	/** ******************物流信息*************************** */

	private String logistics_type = "EMS";// 物流名称.

	private String logistics_fee = "0.0";// 物流费用.

	private String logistics_payment = "SELLER_PAY";// 买家承担运费.

	/** ******************签名信息及返回通知********************************* */
	private String sign;// 签名，计算所得.

	private String return_url;// 支付返回地址

	/**
	 * 构造函数.
	 * 
	 * @param body
	 *            商品描述
	 * @param subject
	 *            商品名称
	 * @param price
	 *            商品单价
	 * @param quantity
	 *            商品数量
	 * @param show_url
	 *            商品展示地址
	 * @param discount
	 *            商品折扣
	 * @param out_trade_no
	 *            订单号
	 * @param seller_email
	 *            卖家支付宝帐户
	 * @param logistics_type
	 *            物流名称
	 * @param logistics_fee
	 *            物流费用
	 * @param return_url
	 *            支付返回地址
	 */
	public Alipay(String body, String subject, String price, String quantity,
			String show_url, String discount, String out_trade_no,
			String seller_email, String logistics_type, String logistics_fee,
			String return_url) {

		// 设置一些常量.
		this.setPayment_type("1");
		this.setService("trade_create_by_buyer");
		this.setSign_type("MD5");
		this.setInput_charset("utf-8");
		this.setLogistics_payment("SELLER_PAY");

		// 设置配置信息.
		this.setPartner(ConfigHelper.getPropertyValue("alipay.partner"));
		this.setKey(ConfigHelper.getPropertyValue("alipay.key"));

		this.setBody(body);
		this.setSubject(subject);
		this.setPrice(price);
		this.setQuantity(quantity);
		this.setShow_url(show_url);
		this.setDiscount(discount);
		this.setOut_trade_no(out_trade_no);
		this.setSeller_email(seller_email);
		this.setLogistics_type(logistics_type);
		this.setLogistics_fee(logistics_fee);
		this.setReturn_url(return_url);

		// 设置签名.
		String paygateway = ConfigHelper.getPropertyValue("alipay.paygateway");
		String sign = Payment.CreateUrl(paygateway, service, sign_type,
				out_trade_no, input_charset, partner, key, seller_email, body,
				subject, price, quantity, show_url, payment_type, discount,
				logistics_type, logistics_fee, logistics_payment, return_url);
		this.setSign(sign);
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getQuantity() {
		return quantity;
	}

	public void setQuantity(String quantity) {
		this.quantity = quantity;
	}

	public String getShow_url() {
		return show_url;
	}

	public void setShow_url(String show_url) {
		this.show_url = show_url;
	}

	public String getPayment_type() {
		return payment_type;
	}

	public void setPayment_type(String payment_type) {
		this.payment_type = payment_type;
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}

	public String getOut_trade_no() {
		return out_trade_no;
	}

	public void setOut_trade_no(String out_trade_no) {
		this.out_trade_no = out_trade_no;
	}

	public String getService() {
		return service;
	}

	public void setService(String service) {
		this.service = service;
	}

	public String getSign_type() {
		return sign_type;
	}

	public void setSign_type(String sign_type) {
		this.sign_type = sign_type;
	}

	public String getInput_charset() {
		return input_charset;
	}

	public void setInput_charset(String input_charset) {
		this.input_charset = input_charset;
	}

	public String getPartner() {
		return partner;
	}

	public void setPartner(String partner) {
		this.partner = partner;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getSeller_email() {
		return seller_email;
	}

	public void setSeller_email(String seller_email) {
		this.seller_email = seller_email;
	}

	public String getLogistics_type() {
		return logistics_type;
	}

	public void setLogistics_type(String logistics_type) {
		this.logistics_type = logistics_type;
	}

	public String getLogistics_fee() {
		return logistics_fee;
	}

	public void setLogistics_fee(String logistics_fee) {
		this.logistics_fee = logistics_fee;
	}

	public String getLogistics_payment() {
		return logistics_payment;
	}

	public void setLogistics_payment(String logistics_payment) {
		this.logistics_payment = logistics_payment;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getReturn_url() {
		return return_url;
	}

	public void setReturn_url(String return_url) {
		this.return_url = return_url;
	}

}
